// import 'pixi'
// import 'p2'
import Phaser from 'phaser-ce'

import BootState from './states/Boot'
import LoadingState from './states/Loading'
import StartState from './states/Start'
import Play from './states/Play'
// import GameState from './states/Game'
import config from './config'

class Game extends Phaser.Game {
  constructor () {
    const width = window.gameWidth
    const height = window.gameHeight

    const conf = {
      width: width,
      height: height,
      renderer: Phaser.CANVAS,
      transparent: false,
      antialias: false
      // resolution: window.devicePixelRatio
      // resolution: window.devicePixelRatio
      // zoom: 1 / window.devicePixelRatio // Set the zoom to the inverse of the devicePixelRatio

    }
    super(conf)

    this.state.add('Boot', BootState, true)
    this.state.add('Loading', LoadingState)
    this.state.add('Start', StartState)
    this.state.add('Play', Play)

    this.state.start('Boot')
  }
}

window.game = new Game()
// if ('serviceWorker' in navigator) {
//   window.addEventListener('load', () => {
//     navigator.serviceWorker.register('/service-worker.js').then(registration => {
//       console.log('SW registered: ', registration)
//     }).catch(registrationError => {
//       console.log('SW registration failed: ', registrationError)
//     })
//   })
// }
